<?php
/**
 * Class configuring the connection to DB MySQL.
 */
class Dbconnect
{
	public $dblocation;
    public $login;
    public $pass;
    public $dbname;
    public $query;
    protected static $_instance;  
    
    private function __construct() 
    {	
    	$this->dblocation = DB_SERVER;
		$this->login = DB_LOGIN;
		$this->pass = DB_PASS;
		$this->dbname = DB_NAME;
        $dbConnect = mysql_connect($this->dblocation, $this->login, $this->pass);   
  		if (!$dbConnect)   
  		{   
	    	 echo "<p>Error connect server DB</p>";   
	   		 exit();   
  		}  
  		if (!mysql_select_db($this->dbname, $dbConnect))   
  		{   
	   		 echo "<p>Error connect DB mySQL</p>";   
	   		 exit();   
  		}   
    }

    /**
 	 * Return returns data from the database upon query
 	 * 
 	 * @query  string SQL query
 	 * 
 	 * @return result table
	 */ 
	public function query($query) 
	{
    	$ver = mysql_query($query);   
  		if(!$ver)
  		{   
   		 	echo "<p>Error in query.</p>";   
   		 	exit();   
 		}   
  		return  $ver; 
	}
	
	/**
     * Get instance of class
     */  
    public static function getInstance() 
    {  
        
        if (null === self::$_instance) 
        {  
        	self::$_instance = new self();  
        }  
        return self::$_instance;  
    }  
    
	private function __clone()
    {  
    }
}



